<!DOCTYPE html > 
<html>
<head> 
<base>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <title>订单审核</title>
	<link rel="stylesheet" href="../../layui/css/layui.css" media="all">
  <style>
    body{margin: 10px;}
    .demo-carousel{height: 300px; line-height: 300px; text-align: center;}
	
	.demoTable {
		z-index: 10px;
	}
	
	#addReload {
		position: absolute;
		top: 0%;
		z-index: 10000;
		background: rgb(0, 0, 0, 0.9);
		width: 100%;
		height: 100%;
		display: none;
	}
	#tijiao {
		position: absolute;
		top: 0%;
		z-index: 10000;
		background: rgb(0, 0, 0, 0.9);
		width: 100%;
		height: 100%;
		display: none;
	}
	
	#addOperation {
		position: absolute;
		left: 30%;
		top: 15%;
		width: 40%;
		background: white;
	}
    
  </style>
</head>
<body>
	<div class="demoTable">
	  搜索关键字：
		<div class="layui-inline" >
			<input class="layui-input" name="id" id="demoReload"
				autocomplete="off">
		</div>
		
		时间：
		<div class="layui-input-inline">
      	  	<input name="date" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" type="text">
      	</div>
      	——<div class="layui-input-inline">
      	  	<input name="date" id="date1" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" type="text">
      	</div>
		<button class="layui-btn" data-type="reload">搜索</button>
	</div>
	<table class="layui-hide" id="goods" lay-filter="demo"></table>
	<div id="addReload">
	 		<div id="addOperation">
			 	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
				  <legend>审核信息填写</legend>
				</fieldset>
				<form class="layui-form" id="shForm" action="../../FdPurchase/zjlsh.action" method="post" onsubmit="return toVaild()" >
				
				  <div class="layui-form-item">
				    <label class="layui-form-label">审核部门</label>
				    <div class="layui-input-block">
				      <input type="hidden" name="fdPoId" id="fdPoId">
				      <input type="hidden" name="fdSunnum" id="fdSunnum">
				      <input type="hidden" name="fdSumprice" id="fdSumprice">
				      <input type="hidden" name="fdNumber" id="fdNumber">
				      <input type="hidden" name="auditSection" value="总经理审核">
				      <input type="text" maxlength="20" lay-verify="required" value="总经理审核" autocomplete="off" class="layui-input layui-disabled" disabled style="width:280px;">
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">订单名称</label>
				    <div class="layui-input-block">
				      <input type="hidden"  value="3" name="isva">
				      <input type="text" name="roleCode" maxlength="20" value="分店采购订单"  autocomplete="off" class="layui-input layui-disabled" disabled style="width:280px;">
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">是否通过</label>
				    <div class="layui-input-block" style="width:200px;">
				       <select name="auditPass"  lay-verify="required" lay-filter="isvas" lay-search="" id="isvas">
				       	  <option value="1">是</option>
				          <option value="0">否</option>
				        </select>
				    </div>
				  </div>
				  <div class="layui-form-item layui-form-text" id="auditCause">
			    	<label class="layui-form-label">审核意见</label>
				    <div class="layui-input-block">
				      <textarea placeholder="请输入内容" lay-verify="required" maxlength="200" style="width:280px;" name="auditCause" class="layui-textarea"></textarea>
				    </div>
			  	  </div>
				  <div class="layui-form-item">
				    <div class="layui-input-block">
				      <input type="submit" class="layui-btn" lay-submit="" lay-filter="roleAdd" value="提交">
				      <button id="closeAdd" type="reset" class="layui-btn layui-btn-primary" >取消</button>
				    </div>
				  </div>
			 </form>
		 </div>
	 </div>
	 <!-- 提交 -->
	 <div id="tijiao">
	 		<div id="addOperation">
			 	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
				  <legend>审核信息填写</legend>
				</fieldset>
				<form class="layui-form" id="shForms" action="../../FdPurchase/zjltjsh.action" method="post" onsubmit="return toVaild()" >
				
				  <div class="layui-form-item">
				    <label class="layui-form-label">审核部门</label>
				    <div class="layui-input-block">
				      <input type="hidden" name="fdPoId" id="fdPoIds">
				      <input type="hidden" name="auditSection" value="总经理重新提交审核">
				      <input type="text" maxlength="20" lay-verify="required" value="总经理重新提交审核" autocomplete="off" class="layui-input layui-disabled" disabled style="width:280px;">
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">订单名称</label>
				    <div class="layui-input-block">
				      <input type="hidden"  value="3" name="isva">
				      <input type="text" name="roleCode" maxlength="20" value="分店采购订单"  autocomplete="off" class="layui-input layui-disabled" disabled style="width:280px;">
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">是否通过</label>
				    <div class="layui-input-block" style="width:200px;">
				       <select name="auditPass"  lay-verify="required" lay-filter="isvas" lay-search="" id="isvas">
				       	  <option value="1">是</option>
				          <option value="0">否</option>
				        </select>
				    </div>
				  </div>
				  <div class="layui-form-item layui-form-text" id="auditCauses">
			    	<label class="layui-form-label">审核意见</label>
				    <div class="layui-input-block">
				      <textarea placeholder="请输入内容" lay-verify="required" maxlength="200" style="width:280px;" name="auditCause" class="layui-textarea"></textarea>
				    </div>
			  	  </div>
				  <div class="layui-form-item">
				    <div class="layui-input-block">
				      <input type="submit" class="layui-btn" lay-submit="" lay-filter="roleAdd" value="提交">
				      <button id="quxiao" type="reset" class="layui-btn layui-btn-primary" >取消</button>
				    </div>
				  </div>
			 </form>
		 </div>
	 </div>
<script type="text/html" id="xx">
  <a class="layui-btn layui-btn-xs" lay-event="chakan" id="dindanxx">查看订单详情</a>
  <a class="layui-btn layui-btn-xs" lay-event="chakansh" id="shenhecx">查看审核详情</a>
</script>
<script  language="javascript">
		function toVaild(){
			var val = document.getElementById("fdSumprice").value;
			$.ajax({
                url:"../../FdPurchase/jiage.action",
                type: "post",
                dataType:"json",
                cache:false,
                async: false,
                success: function(obj){
	                if(obj>val){
	  				  	return true;
	                 }else{
	                	 layer.msg('亲，财务金额不够了!!!', {
	       				  	icon: 5,
	       				  	time: 2000 //1秒关闭（如果不配置，默认是3秒）
	       					}, function(){
	       				  
	       				 });
	                     return false;
	                 }
                }
             });
           }
    </script>
<script src="../../layui/layui.js"></script>
<script src="../../res/js/jquery-1.10.2.js"></script>
<script type="text/html" id="barDemo">
	{{panduan(d)}}
</script>
<script>
function panduan(d){
	var  html = "";
	if(d.fdPoState=="财务已审核，等待总经理审核"){
		html='<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="shenhe" id="shenhe">审核</a>';
	}else if(d.fdPoState=="订单已被总店驳回"){
		html='<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="cxtj" id="cxtj">重新提交</a>';
	}
	return html;
	
}


layui.use(['laydate','form', 'laypage', 'layer', 'table', 'upload', 'element'], function(){
  var laydate = layui.laydate //日期
  ,laypage = layui.laypage //分页
  layer = layui.layer //弹层
  ,table = layui.table //表格
  ,upload = layui.upload //上传
  ,form=layui.form
  ,element = layui.element; //元素操作
  
  //日期
  laydate.render({
	    elem: '#date'
  });
  laydate.render({
	    elem: '#date1'
  });
  
  //监听Tab切换
  element.on('tab(demo)', function(data){
    layer.msg('切换了：'+ this.innerHTML);
    console.log(data);
  });
  //执行一个 table 实例
  table.render({
     elem: '#goods'
    ,height: 474
    ,url: '../../FdPurchase/findAllzjlshenhe.action' //数据接口
    ,page: true //开启分页
    ,method:'post'
    ,cols: [[ //表头
       {type:'checkbox', fixed: 'left'}
      ,{field: 'fdPoId', title: '采购订单编号', width:150, fixed: 'left'}
      ,{field: 'manId', title: '用户ID', width:120}
      ,{field: 'fdPoPerson', title: '采购人员', width:120}
      ,{field: 'fdSunnum', title: '采购总数量', width:120}
      ,{field: 'fdSumprice', title: '采购总价格', width: 120}
      ,{field: 'fdPoTimes', title: '采购时间', width: 150}
      ,{field: 'fdPoState', title: '采购状态', width: 220}
      ,{field: 'fdPoRemark', title: '采购备注', width: 120}
      ,{field: 'fdNumber', title: '批次号', width: 120}
      ,{fixed: 'right',title: '查询信息', width: 210, align:'center', toolbar: '#xx'}
      ,{fixed: 'right',title: '操作', width: 140, align:'center', toolbar: '#barDemo'}
    ]]
  	,id: 'testReload'
  });
  
  //监听工具条
  table.on('tool(demo)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
    var data = obj.data //获得当前行数据
    ,layEvent = obj.event; //获得 lay-event 对应的值
    var fdPoId = data.fdPoId;
    if(layEvent === 'shenhe'){
      //id
      var id=data.fdPoId;
      //数量
      var fdSunnum=data.fdSunnum;
      //价格
      var fdSumprice=data.fdSumprice;
      //批次号
      var fdNumber=data.fdNumber;
      
      $("#fdPoId").val(id);
      $("#fdSunnum").val(fdSunnum);
      $("#fdSumprice").val(fdSumprice);
      $("#fdNumber").val(fdNumber);
      form.render();
      $('#addReload').css('display', 'block');
    } else if(layEvent==='chakan'){
    	var fdPoId=data.fdPoId;
    	sessionStorage["fdPoId"]=fdPoId;
    	//location.href="pages/wsz/FodDetailList.jsp";
    	var url="../yuanwei/purchaseList.html?fdPoId="+fdPoId;
    	
	    	layer.open({
	 			  type: 2,
	 			  area : ['76%' , '75%'],//弹出框大小
	 			  shift:1,//弹出框动画效果
	 			  content: [url,'on'] //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
	    	});
	}else if(layEvent==='cxtj'){
		//id
	    var id=data.fdPoId;
	    $("#fdPoIds").val(id);
	    form.render();
	    $('#tijiao').css('display', 'block');
	}else if(layEvent==='chakansh'){
		var fdPoId=data.fdPoId;
		sessionStorage["fdPoId"]=fdPoId;
		var url="../yuanwei/purchaseshList.html?fdPoId="+fdPoId;
		layer.open({
			  type: 2,
			  area : ['76%' , '75%'],//弹出框大小
			  shift:1,//弹出框动画效果
			  content: [url,'on'] //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
  		});
	}
  });
  
	//条件查询
	var $ = layui.$;

	$('.demoTable .layui-btn').on('click', function() {
		var demoReload = $('#demoReload');
		//执行重载
		table.reload('testReload', {
			page : {
				curr : 1
			//重新从第 1页开始
			},
			where : {
				FdPoPerson : demoReload.val(),
				dateOne: $("#date").val(),
				dateTwo: $("#date1").val()
			}
			
		});
	}); 
	$('#closeAdd').on('click', function() {
		$('#addReload').css('display', 'none');
	});
	$('#quxiao').on('click', function() {
		$('#tijiao').css('display', 'none');
	});
});
  
  
</script>
</body>
</html>